<template>
	<view class="page chat-page">
		<!-- <navbar title="试卷列表" /> -->
		
		<view class="exam-container">
			<ExamList @exam-click="handleExamClick" @loaded="handleDataLoaded" />
		</view>

		<!-- <view class="start-button-container">
			<view class="start-button" @click="handleStartClick">
				<text class="start-button-text">开始</text>
			</view>
		</view> -->
	</view>
</template>

<script>
	//import listmx from "@/mixins/list.js";
	import ExamList from '@/components/exam/ExamList.vue';
	
	export default {
		components: {
			ExamList
		},
		// mixins: [listmx],
		data() {
			return {
				examData: []
			};
		},
		computed: {},
		onLoad() {
			if (uni.getStorageSync("token")) {
				this.$store.commit('getUserInfo')
			}
		},
		methods: {
			// 处理试卷点击事件
			handleExamClick(exam) {
				console.log('点击了试卷:', exam);
				// 这里可以添加导航到试卷详情页的逻辑

				// uni.navigateTo({
				//   url: `/pages_order/topic/index`
				// });

                this.handleStartClick(exam.examId)
			},
			
			// 处理数据加载完成事件
			handleDataLoaded(data) {
				this.examData = data.list;
				console.log('试卷列表数据加载完成:', data);
			},
			
			// 处理开始按钮点击事件
			handleStartClick(examId) {
				this.$api('userExamsStart', {
                    examId
				})
				.then(res => {
					if(res.code == 200){
						this.$store.commit('setUserExams', res.data)
						uni.navigateTo({
							url: '/pages_order/topic/index'
						})
					}
				})
				
			}
		},
	};
</script>

<style scoped lang="scss">
	.chat-page {
		display: flex;
		flex-direction: column;
		height: 100vh;
		background-color: #f5f5f5;
	}

	.exam-container {
		flex: 1;
		overflow-y: auto;
		padding-bottom: 30rpx;
	}
	
	.start-button-container {
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		display: flex;
		justify-content: center;
		align-items: center;
		width: 100%;
		z-index: 10;
	}
	
	.start-button {
		width: 200rpx;
		height: 200rpx;
		border-radius: 50%;
		background: linear-gradient(135deg, #22a6f1, #1a7ad9);
		display: flex;
		justify-content: center;
		align-items: center;
		box-shadow: 0 10rpx 20rpx rgba(26, 122, 217, 0.3);
		transition: all 0.3s ease;
		animation: pulse 2s infinite;
	}
	
	.start-button:active {
		transform: scale(0.95);
		box-shadow: 0 5rpx 10rpx rgba(26, 122, 217, 0.2);
	}
	
	.start-button-text {
		color: #ffffff;
		font-size: 40rpx;
		font-weight: bold;
	}
	
	@keyframes pulse {
		0% {
			transform: scale(1);
			box-shadow: 0 10rpx 20rpx rgba(26, 122, 217, 0.3);
		}
		50% {
			transform: scale(1.05);
			box-shadow: 0 15rpx 25rpx rgba(26, 122, 217, 0.4);
		}
		100% {
			transform: scale(1);
			box-shadow: 0 10rpx 20rpx rgba(26, 122, 217, 0.3);
		}
	}

	.chat-container {
		flex: 1;
		padding: 20rpx;
		overflow: hidden;
		box-sizing: border-box;
	}

	.chat-footer {
		padding: 20rpx;
		background-color: #f8f8f8;
		border-top: 1rpx solid #e0e0e0;
	}

	.input-box {
		display: flex;
		align-items: center;
		background-color: #ffffff;
		border-radius: 10rpx;
		padding: 10rpx 20rpx;

		input {
			flex: 1;
			height: 70rpx;
			font-size: 28rpx;
		}

		.action-buttons {
			display: flex;
			align-items: center;

			.upload-btn {
				padding: 5rpx 20rpx;
			}

			.more-btn {
				background-color: #e8ecef;
				color: #ffffff;
				padding: 5rpx 20rpx;
				border-radius: 8rpx;
				margin-left: 10rpx;

				text {
					font-size: 40rpx;
				}
			}

			.send-btn {
				background-color: #22a6f1;
				color: #ffffff;
				padding: 10rpx 30rpx;
				border-radius: 8rpx;
				margin-left: 10rpx;

				text {
					font-size: 28rpx;
				}
			}
		}
	}

	.bottom-menu {
		position: fixed;
		bottom: 55px;
		left: 0;
		right: 0;
		background-color: #f6f5f5;
		border-top: 1px solid #ede7e7;
		padding: 10px;
		display: flex;
		/* 允许子元素换行排列 */
		flex-wrap: wrap;
	}

	.menu-item {
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		width: 40px;
		height: 40px;
		margin: 30px 0px 10px 43px;
		padding: 10px;
		background-color: #fff;
		border-radius: 20%;
		cursor: pointer;
	}

	.up-item {
		position: absolute;
		left: 50%;
		top: 10;
		transform: translate(-10%);
		width: 100px;
		height: 100px;
	}

	.mask {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background-color: rgba(0, 0, 0, 0.5);
	}
</style>